/* ###################################### */
/* ###     Util Engine, by Kalith    ### */
/* ###################################### */
/*              Types header              */
/*                                        */
/*                                        */

#ifndef Util_UTILS_TYPES_H
#define Util_UTILS_TYPES_H

#include "Config.h"

#ifdef MSVC
    // Note : Microsoft's Visual C++ doesn't include the round function.
    // Definition of this function is in Util_utils_math.cpp.
    long round( double x );
#else
    // Forward declaration to avoid including <cmath>.
    // Used by some template functions.
    #ifdef Util_LINUX
    extern "C" double round( double x ) throw();
    #else
    extern "C" double __cdecl round( double x );
    #endif
#endif

namespace Util
{
    template<class T>               class StrType;
    template<class T>               class BoolVar;
    template<class T>               class IntType;
    template<class T>               class UintType;
    template<class T>               class FloatType;
    template<class T, class C>      class CtnrF;
    template<class T>               class Ctnr;
    template<class T, uint N>       class Array;
    template<class T, class N>      class Pair;
    template<class T>               class Range;
    template<class Key, class Data> class Map;
    template<class Key, class Data> class Multimap;
                                    class Nullptr;
    template<class T>               class Ptr;
    template<class T>               class Refptr;
    template<class T>               class Wptr;

    /// Stores various informations about a type.
    template<class T>
    class TypeTraits
    {
    public :
        typedef T         Type;
        typedef T         BaseType;
        typedef T         UtilType;
        typedef T&        RefType;
        typedef T const & CRefType;
        typedef T*        PointerType;

        static inline CRefType GetValue(CRefType m) { return m; }
    };

    /// Allows explicit string conversion and operator overloading.
    /** This class is used for explicit constructors and +, += and <<
    *   operators. It is specialized for most commonly used string
    *   types : Str and UStr.<br>
    *   \note T : character type to convert to
    *         N : type to convert from
    */
    template<class T, class N> class StringConverter;
}

#include "Bool.h"
#include "Int.h"
#include "UInt.h"
#include "Floats.h"
#include "Str.h"
#include "Conversion.h"

namespace Util
{
    typedef IntType<char>      Char;
    typedef IntType<short>     Short;
    typedef IntType<int>       Int;
    typedef IntType<long>      Long;
    typedef IntType<long long> LLong;
    typedef IntType<ptrdiff_t> Ptrdiff;

    typedef UintType<uchar>              UChar;
    typedef UintType<ushort>             UShort;
    typedef UintType<uint>               UInt;
    typedef UintType<ulong>              ULong;
    typedef UintType<unsigned long long> ULLong;

    typedef FloatType<float>       Float;
    typedef FloatType<double>      Double;
    typedef FloatType<long double> LDouble;

    typedef StrType<string_element> Str;
    typedef StrType<uint>           UStr;

    long StringToInt(const Str& s);
    long StringToInt(const UStr& s);
    ulong StringToUInt(const Str& s);
    ulong StringToUInt(const UStr& s);
    double StringToFloat(const Str& s);
    double StringToFloat(const UStr& s);
}

#include "Nullptr.h"
#include "Ptr.h"
#include "Refptr.h"
#include "Wptr.h"
#include "Ctnr.h"
#include "Array.h"
#include "Map.h"
#include "Multimap.h"
#include "MakePair.h"

#endif
